package com.corona.game;

import com.corona.Game;

import java.util.Locale;

/* compiled from: Battle.java */
/* access modifiers changed from: package-private */
/* loaded from: pokewilds.jar:com/pkmngen/game/ChanceToRun.class */
public class ChanceToRun extends Action {
    public Action.Layer layer = Action.Layer.gui_120;

    public ChanceToRun(Game game, Action nextAction) {
        super(new Object[0]);
        this.nextAction = nextAction;
    }

    @Override // com.corona.game.Action
    public String getCamera() {
        return "gui";
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        int x = (game.battle.oppPokemon.currentStats.get("speed").intValue() % 256) * 2;
        System.out.println("Chance to run, x: " + String.valueOf(x));
        if (x > 255) {
            game.insertAction(new DisplayText(game, "Wild " + game.battle.oppPokemon.nickname.toUpperCase(Locale.ROOT) + " ran!", (String) null, (Action) null, new SplitAction(new OppPokemonFlee(game, new SplitAction(new BattleFadeOut(game, null), new BattleFadeOutMusic(game, null))), new WaitFrames(game, 8, new PlayMusic("run1", (Action) null)))));
            game.player.adrenaline = 0;
            game.actionStack.remove(this);
            return;
        }
        if (game.battle.oppPokemon.angry > 0) {
            x *= 2;
            if (x > 255) {
                x = 255;
            }
        } else if (game.battle.oppPokemon.eating > 0) {
            x /= 4;
        }
        if (game.map.rand.nextInt(256) < x) {
            game.insertAction(new DisplayText(game, "Wild " + game.battle.oppPokemon.nickname.toUpperCase(Locale.ROOT) + " ran!", (String) null, (Action) null, new SplitAction(new OppPokemonFlee(game, new SplitAction(new BattleFadeOut(game, null), new BattleFadeOutMusic(game, null))), new WaitFrames(game, 8, new PlayMusic("run1", (Action) null)))));
            game.player.adrenaline = 0;
            game.actionStack.remove(this);
            return;
        }
        game.insertAction(this.nextAction);
        game.actionStack.remove(this);
    }
}
